package com.ewanghuiju.app.presenter.watermail;

import com.ewanghuiju.app.base.RxPresenter;
import com.ewanghuiju.app.base.contract.watermail.WaterOrderDetailsContract;
import com.ewanghuiju.app.model.DataManager;
import com.ewanghuiju.app.model.bean.response.WaterOrderListResponBean;
import com.ewanghuiju.app.model.http.response.Optional;
import com.ewanghuiju.app.util.RxUtil;
import com.ewanghuiju.app.widget.CommonSubscriber;

import javax.inject.Inject;

/**
 * @author sj  qq:751943509
 * @class 拼团订单详情
 * @time 2020/2/16
 */
public class WaterOrderDetailsPresenter extends RxPresenter<WaterOrderDetailsContract.View> implements WaterOrderDetailsContract.Presenter {

    private DataManager mDataManager;

    @Inject
    public WaterOrderDetailsPresenter(DataManager mDataManager) {
        this.mDataManager = mDataManager;
    }

    @Override
    public void getData(String order_id) {
        addSubscribe(mDataManager.getIntegralconversioninfo(order_id)
                .compose(RxUtil.rxSchedulerHelper())
                .compose(RxUtil.handleMyResultCannull())
                .subscribeWith(new CommonSubscriber<Optional<WaterOrderListResponBean>>(mView) {
                    @Override
                    public void onNext(Optional<WaterOrderListResponBean> optional) {
                        if (mView != null)
                            mView.showContent(optional.getIncludeNull());
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                })
        );
    }

}
